    //��ʱ����Ӧ��
#include<iostream>
#include<thread>
#include<mutex>
#include<chrono>
using namespace std;

timed_mutex tmux;
void ThreadMainTime(int i)
{
    for(;;)
    {
        if (!tmux.try_lock_for(chrono::milliseconds(500)))
        {
            cout<<i<<"[try_lock_for timeout]"<<endl;
            continue;
        }
        cout<<i<<"[in]"<<endl;
        this_thread::sleep_for(2000ms);
        tmux.unlock();
        this_thread::sleep_for(1ms);
    }
}



int main()
{
    for(int i=0;i<3;i++)
    {
        thread th(ThreadMainTime,i+1);
        th.detach();
    }
    getchar();
}